/**************************************************************************************************************************** Licensed Materials - Property of IBM BI and PM: QFW © Copyright IBM Corp. 2005, 2010 US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *****************************************************************************************************************************/ function LogTreeNode( id, parentNode, nestedParentNode, tree, content, width, height, boxColor, title ) { this.id = id; this.parentNode = parentNode; this.tree = tree; this.content = content; this.visible = true; if( title ) this.title = title; if( width != null ) this.width = width; else this.width = (tree.config.nodeWidth)? tree.config.nodeWidth: 0; if( height != null ) this.height = height; else this.height = (tree.config.nodeHeight)? tree.config.nodeHeight: 0; this.X = 0; this.Y = 0; this.groupHeight = 0; this.groupWidth = 0; this.groupX = 0; this.groupY = 0; this.boxColor = boxColor; this.connectorElems = []; this.childNodes = []; this.connectorNestedElems = []; this.nestedChildNodes = []; this.createContent(); if( id >= 0 ) { this.tree.config.tempTreeContainer.appendChild( this.contentNode ); if( this.contentNode.offsetWidth > this.width - 10 ) { this.width = this.contentNode.offsetWidth + 10; } this.contentHeight = this.contentNode.offsetHeight; this.tree.config.tempTreeContainer.removeChild( this.contentNode ); this.tree.config.tempTreeContainer.innerHTML = ""; } } LogTreeNode.prototype.updateLocation_nestedInside = function updateLocation_nestedInside() { if( this.nestedChildNodes.length == 0 ) return; var nestedChildGroupY = this.Y + this.contentHeight; for( var i = 0; i < this.nestedChildNodes.length; ++i ) { if( i == 0 ) nestedChildGroupY += this.tree.config.nestedChildGroupYMarginTop; else nestedChildGroupY += this.tree.config.siblingMargin; var child = this.nestedChildNodes[i]; child.updateLocation( this.X + this.tree.config.nestedChildGroupXMargin, nestedChildGroupY ); nestedChildGroupY += child.groupHeight; if( this.width < 2 * this.tree.config.nestedChildGroupXMargin + child.groupWidth ) this.width = 2 * this.tree.config.nestedChildGroupXMargin + child.groupWidth; } this.height = nestedChildGroupY + this.tree.config.nestedChildGroupYMarginBottom - this.Y; } LogTreeNode.prototype.updateLocation_children = function updateLocation_children( childGroupX, childGroupY ) { var i = 0; this.groupWidth = this.width; for( ; i < this.childNodes.length; ++i ) { if( i > 0 ) childGroupY += this.tree.config.siblingMargin; var child = this.childNodes[i]; child.updateLocation( childGroupX, childGroupY ); childGroupY += child.groupHeight; if( this.groupWidth < this.width + this.tree.config.levelMargin + child.groupWidth ) this.groupWidth = this.width + this.tree.config.levelMargin + child.groupWidth; } return childGroupY; } LogTreeNode.prototype.updateLocation = function updateLocation( groupX, groupY ) { this.groupX = this.X = groupX; this.groupY = groupY; if( this.tree.config.bNestedInside ) this.updateLocation_nestedInside(); var childGroupX = this.X + this.width + this.tree.config.levelMargin; this.groupWidth = this.width; var childGroupYBottom = this.updateLocation_children( childGroupX, groupY ); this.groupHeight = childGroupYBottom - groupY; if( this.groupHeight < this.height ) { this.updateLocation_children( childGroupX, groupY + this.height/2 - this.groupHeight/2 ); this.groupHeight = this.height; this.Y = groupY; } else if( this.childNodes.length == 1 && this.tree.config.bNestedUnder ) this.Y = this.childNodes[0].Y; else this.Y = this.groupHeight / 2 - this.height / 2 + this.groupY; if( this.tree.config.bNestedUnder ) this.updateLocaltion_nestedUnder(); } LogTreeNode.prototype.updateLocation_nestedUnder = function updateLocation_nestedUnder() { var nestedChildGroupX = this.X; for( var i = 0; i < this.nestedChildNodes.length; ++i ) { if( i == 0 ) this.groupHeight += this.tree.config.nestedChildGroupYMarginTop; else this.groupHeight += this.tree.config.siblingMargin; var child = this.nestedChildNodes[i]; child.updateLocation( nestedChildGroupX, this.groupHeight + this.groupY ); this.groupHeight += child.groupHeight; if( this.groupWidth < nestedChildGroupX + child.groupWidth ) this.groupWidth = nestedChildGroupX + child.groupWidth; } } LogTreeNode.prototype.createContent = function createContent() { this.contentNode = document.createElement( "div" ); if( this.title ) { var title = document.createElement( "b" ); title.innerHTML = this.title; this.contentNode.appendChild( title ); } var info = document.createElement( "div" ); //info.style.marginLeft = 10; info.innerHTML = this.content; this.contentNode.appendChild( info ); } LogTreeNode.prototype.createElement = function createElement() { if( this.id < 0 ) return null; var v_dArcsize = 0.20; if( this.tree.config.bNestedInside && this.nestedChildNodes.length > 0 ) v_dArcsize = 0.05; this.tree.tempDiv.innerHTML = ""; this.elem = this.tree.tempDiv.firstChild; this.tree.container.appendChild( this.elem ); this.elem.id = this.id; this.elem.style.position = "absolute"; this.elem.style.top = this.Y; this.elem.style.left = this.X; this.elem.style.height = this.height; this.elem.style.width = this.width; this.elem.style.paddingTop = 3; this.elem.style.paddingBottom = 3; this.elem.style.paddingLeft = 3; this.elem.style.paddingRight = 3; if( this.boxColor ) { //if( !(this.tree.config.bNestedInside && this.nestedChildNodes.length > 0) ) this.elem.fillColor = this.boxColor; } this.elem.appendChild( this.contentNode ); return this.elem; } var plID = 0; var arrAngle = 0.25; var arrLength = 7; LogTreeNode.prototype.createConnector = function createConnector( toChildOrdinal ) { var childNode = this.childNodes[ toChildOrdinal ]; var connectorElem = document.createElement( "v:polyline" ); this.tree.container.appendChild( connectorElem ); //defines points and draws line and arrowhead var A = (this.X + this.width) + "," + (this.Y + this.height/2); var B = (3*this.X + 3*this.width + childNode.X)/4 + "," + (this.Y + .45*this.height ); var C = (3*this.X + 3*this.width + childNode.X)/4 + "," + (this.Y + .55*this.height ); var D = childNode.X + "," + (childNode.Y + childNode.height/2); var angle = Math.atan( ( (childNode.Y + childNode.height/2) - (this.Y + this.height/2) ) / ( childNode.X - (this.X + this.width) ) ); var B1 = (this.X + this.width + arrLength * Math.cos(angle+arrAngle)) + "," + (this.Y + this.height/2 + arrLength * Math.sin(angle+arrAngle)); var C1 = (this.X + this.width + arrLength * Math.cos(angle-arrAngle)) + "," + (this.Y + this.height/2 + arrLength * Math.sin(angle-arrAngle)); connectorElem.points.value = A +" "+ B1 +" "+ A +" "+ C1 +" "+ A +" "+ D; this.connectorElems[toChildOrdinal] = connectorElem; } LogTreeNode.prototype.createNestingConnector = function createConnector( toChildOrdinal ) { if( !this.tree.config.bNestedUnder ) return; var childNode = this.nestedChildNodes[ toChildOrdinal ]; var connectorElem = document.createElement( "v:polyline" ); this.tree.container.appendChild( connectorElem ); //defines points and draws line and arrowhead var A = (this.X + 10) + "," + (this.Y + this.height); var B = (childNode.X + 10) + "," + (childNode.Y); var C = (this.X + 14) + "," + (this.Y + this.height); var D = (childNode.X + 14) + "," + (childNode.Y); connectorElem.points.value = A +" "+ B +" "+ D +" "+ C; this.connectorNestedElems[toChildOrdinal] = connectorElem; } LogTreeNode.prototype.createSubtree = function createSubtree() { this.createElement(); var i = 0; for( ; i < this.childNodes.length; ++i ) { this.childNodes[i].createSubtree(); if( this != this.tree.rootNode ) this.createConnector( i ); } for( i = 0; i < this.nestedChildNodes.length; ++i ) { this.nestedChildNodes[i].createSubtree(); if( this != this.tree.rootNode ) this.createNestingConnector( i ); } } function LogTree( objectRef, container ) { this.objectRef = objectRef; this.container = document.createElement( "v:group" ); container.appendChild( this.container ); this.container.style.position = "absolute"; this.config = new Object(); this.width = 0; this.height = 0; this.nodes = new Array(); this.tempDiv = document.createElement( "DIV" ); this.rootNode = new LogTreeNode( -1, null, null, this, null ); return this; } LogTree.prototype.UpdateTree = function UpdateTree() { this.rootNode.updateLocation( 0, 0 ); this.rootNode.createSubtree(); this.container.style.width = this.rootNode.groupWidth; this.container.style.height = this.rootNode.groupHeight; this.container.coordsize = "" + this.rootNode.groupWidth + "," + this.rootNode.groupHeight; } LogTree.prototype.add = function add( id, parentId, content, width, height, boxColor, title ) { var v_oParentNode; if( parentId < 0 ) v_oParentNode = this.rootNode; else v_oParentNode = this.nodes[parentId]; var v_oNewNode = new LogTreeNode( id, v_oParentNode, null, this, content, width, height, boxColor, title ); this.nodes[id] = v_oNewNode; v_oParentNode.childNodes.push( v_oNewNode ); return v_oNewNode; } LogTree.prototype.addNested = function addNested( id, nestedParentId, content, width, height, boxColor, title ) { if( !nestedParentId || nestedParentId < 0 ) return this.add( id, -1, content, width, height, boxColor, title ); var v_oParentNode = this.nodes[nestedParentId]; var v_oNewNode = new LogTreeNode( id, null, v_oParentNode, this, content, width, height, boxColor, title ); this.nodes[id] = v_oNewNode; v_oParentNode.nestedChildNodes.push( v_oNewNode ); return v_oNewNode; }